!pip install plotly
import math
import random
from datetime import datetime
from math import factorial, log10, pow
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
from matplotlib import pyplot as plt
from numpy import exp
Dictionary:
IRTD : Initial Random Transmission Delay
TP : Transmission Point
Notation Meanings:
G : Packets per transmission time T
a : Normalized Propagation Delay/Slot size
p : Probability that that transmission medium is idle (medium is ready for transmission)
T : Transmission Time
N : Number of packets accumulated at the end of a TP
N' : Number of packets present at the beginning of a busy period, which is also the number of packets arriving in the last slot of the previous idle slot
q : Prob that medium is busy, therefore continually listen until idle, calculated by 1-q
g : Average arrival rate of new/rescheduled packets during a (mini) slot, calculated by a*G
J_i : ith TP of a busy period
tn : Number of slots elapsed until some packet is transmitted
tn' : First inital random transmission delay of the busy period
Ln : Number of packets present at the starting time of J_i
Ln-n : Number of packets arriving during the gap, tn
Traffic Model Assumptions:
1) Average transmission delay x_bar is large compared to T.
2) Interarrival times of the point process defined by the start of all the packets plus retransmissions are independent and exponentially distributed.
GRAPH_CSV_PATH = "Generated Data/a==0/protocols_generated_points(a=0,p=0.05).csv"
NORMALIZED_PROPAGATION_DELAY = 0
PROB_MEDIUM_IS_IDLE = 0.05
DF = pd.read_csv(GRAPH_CSV_PATH)
X = "Offered Load (G)"
fig = go.Figure()
for idx, protocol in enumerate(DF.columns):
if protocol == X:
continue
fig.add_trace(go.Scatter(
name=protocol,
x=DF[X],
y=DF[protocol],
mode="lines",
showlegend=True))
title = f"Throughput for various access modes (a={NORMALIZED_PROPAGATION_DELAY}, p={PROB_MEDIUM_IS_IDLE})"
fig.update_layout(xaxis_type="log",
title={'text': title,
'y':0.9,
'x':0.45,
'xanchor': 'center',
'yanchor': 'top'},
xaxis_title="G (Offered Channel Traffic)",
yaxis_title="S (Throughput)",)
fig.show()
GRAPH_CSV_PATH = "Generated Data/a==0/protocols_generated_points(a=0,p=0.10).csv"
NORMALIZED_PROPAGATION_DELAY = 0
PROB_MEDIUM_IS_IDLE = 0.10
DF = pd.read_csv(GRAPH_CSV_PATH)
X = "Offered Load (G)"
fig = go.Figure()
for idx, protocol in enumerate(DF.columns):
if protocol == X:
continue
fig.add_trace(go.Scatter(
name=protocol,
x=DF[X],
y=DF[protocol],
mode="lines",
showlegend=True))
title = f"Throughput for various access modes (a={NORMALIZED_PROPAGATION_DELAY}, p={PROB_MEDIUM_IS_IDLE})"
fig.update_layout(xaxis_type="log",
title={'text': title,
'y':0.9,
'x':0.45,
'xanchor': 'center',
'yanchor': 'top'},
xaxis_title="G (Offered Channel Traffic)",
yaxis_title="S (Throughput)",)
fig.show()
GRAPH_CSV_PATH = "Generated Data/a==0/protocols_generated_points(a=0,p=0.15).csv"
NORMALIZED_PROPAGATION_DELAY = 0
PROB_MEDIUM_IS_IDLE = 0.15
DF = pd.read_csv(GRAPH_CSV_PATH)
X = "Offered Load (G)"
fig = go.Figure()
for idx, protocol in enumerate(DF.columns):
if protocol == X:
continue
fig.add_trace(go.Scatter(
name=protocol,
x=DF[X],
y=DF[protocol],
mode="lines",
showlegend=True))
title = f"Throughput for various access modes (a={NORMALIZED_PROPAGATION_DELAY}, p={PROB_MEDIUM_IS_IDLE})"
fig.update_layout(xaxis_type="log",
title={'text': title,
'y':0.9,
'x':0.45,
'xanchor': 'center',
'yanchor': 'top'},
xaxis_title="G (Offered Channel Traffic)",
yaxis_title="S (Throughput)",)
fig.show()
GRAPH_CSV_PATH = "Generated Data/a==0/protocols_generated_points(a=0,p=1).csv"
NORMALIZED_PROPAGATION_DELAY = 0
PROB_MEDIUM_IS_IDLE = 1
DF = pd.read_csv(GRAPH_CSV_PATH)
X = "Offered Load (G)"
fig = go.Figure()
for idx, protocol in enumerate(DF.columns):
if protocol == X:
continue
fig.add_trace(go.Scatter(
name=protocol,
x=DF[X],
y=DF[protocol],
mode="lines",
showlegend=True))
title = f"Throughput for various access modes (a={NORMALIZED_PROPAGATION_DELAY}, p={PROB_MEDIUM_IS_IDLE})"
fig.update_layout(xaxis_type="log",
title={'text': title,
'y':0.9,
'x':0.45,
'xanchor': 'center',
'yanchor': 'top'},
xaxis_title="G (Offered Channel Traffic)",
yaxis_title="S (Throughput)",)
fig.show()
GRAPH_CSV_PATH = "Generated Data/protocols_generated_points(a=0.05,p=0.05).csv"
NORMALIZED_PROPAGATION_DELAY = 0.05
PROB_MEDIUM_IS_IDLE = 0.05
DF = pd.read_csv(GRAPH_CSV_PATH)
X = "Offered Load (G)"
fig = go.Figure()
for idx, protocol in enumerate(DF.columns):
if protocol == X:
continue
fig.add_trace(go.Scatter(
name=protocol,
x=DF[X],
y=DF[protocol],
mode="lines",
showlegend=True))
title = f"Throughput for various access modes (a={NORMALIZED_PROPAGATION_DELAY}, p={PROB_MEDIUM_IS_IDLE})"
fig.update_layout(xaxis_type="log",
title={'text': title,
'y':0.9,
'x':0.45,
'xanchor': 'center',
'yanchor': 'top'},
xaxis_title="G (Offered Channel Traffic)",
yaxis_title="S (Throughput)",)
fig.show()
GRAPH_CSV_PATH = "Generated Data/protocols_generated_points(a=0.05,p=0.10).csv"
NORMALIZED_PROPAGATION_DELAY = 0.05
PROB_MEDIUM_IS_IDLE = 0.10
DF = pd.read_csv(GRAPH_CSV_PATH)
X = "Offered Load (G)"
fig = go.Figure()
for idx, protocol in enumerate(DF.columns):
if protocol == X:
continue
fig.add_trace(go.Scatter(
name=protocol,
x=DF[X],
y=DF[protocol],
mode="lines",
showlegend=True))
title = f"Throughput for various access modes (a={NORMALIZED_PROPAGATION_DELAY}, p={PROB_MEDIUM_IS_IDLE})"
fig.update_layout(xaxis_type="log",
title={'text': title,
'y':0.9,
'x':0.45,
'xanchor': 'center',
'yanchor': 'top'},
xaxis_title="G (Offered Channel Traffic)",
yaxis_title="S (Throughput)",)
fig.show()
GRAPH_CSV_PATH = "Generated Data/protocols_generated_points(a=0.05,p=0.15).csv"
NORMALIZED_PROPAGATION_DELAY = 0.05
PROB_MEDIUM_IS_IDLE = 0.15
DF = pd.read_csv(GRAPH_CSV_PATH)
X = "Offered Load (G)"
fig = go.Figure()
for idx, protocol in enumerate(DF.columns):
if protocol == X:
continue
fig.add_trace(go.Scatter(
name=protocol,
x=DF[X],
y=DF[protocol],
mode="lines",
showlegend=True))
title = f"Throughput for various access modes (a={NORMALIZED_PROPAGATION_DELAY}, p={PROB_MEDIUM_IS_IDLE})"
fig.update_layout(xaxis_type="log",
title={'text': title,
'y':0.9,
'x':0.45,
'xanchor': 'center',
'yanchor': 'top'},
xaxis_title="G (Offered Channel Traffic)",
yaxis_title="S (Throughput)",)
fig.show()
GRAPH_CSV_PATH = "Generated Data/Original Protocol(a=0.01,p=0.1).csv"
NORMALIZED_PROPAGATION_DELAY = 0.01
PROB_MEDIUM_IS_IDLE = 0.10
DF = pd.read_csv(GRAPH_CSV_PATH)
X = "Offered Load (G)"
fig = go.Figure()
for idx, protocol in enumerate(DF.columns):
if protocol == X:
continue
fig.add_trace(go.Scatter(
name=protocol,
x=DF[X],
y=DF[protocol],
mode="lines",
showlegend=True))
title = f"Throughput for various access modes (a={NORMALIZED_PROPAGATION_DELAY}, p={PROB_MEDIUM_IS_IDLE})"
fig.update_layout(xaxis_type="log",
title={'text': title,
'y':0.9,
'x':0.45,
'xanchor': 'center',
'yanchor': 'top'},
xaxis_title="G (Offered Channel Traffic)",
yaxis_title="S (Throughput)",)
fig.show()